/*
 * Copyright 2021 <copyright holder> <email>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FRAME_H
#define FRAME_H

#include "common_include.h"
#include "camera.h"

/**
 * @todo write docs
 */
class Frame
{
public:
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
    typedef std::shared_ptr<Frame> Ptr;
    
    unsigned long id_=0;
    unsigned long keyframe_id_=0; 
    bool is_keyframe_=false;
    
    double time_stamp_; 
    SE3 pose_;
    
    std::mutex pose_mutex_;
    cv::Mat left_image_, right_image_;
    
    std::vector<std::shared_ptr<feature>> feature_left; //???
    std::vector<std::shared_ptr<feature>> feature_right; //???
    
public:
    Frame() {}
    Frame(long id, double time_stamp, const SE3 &pose, const cv::Mat &left, 
          const cv::Mat &right);
    
    SE3 Pose(){
        std::unique_lock<std::mutex> lck(pose_mutex_);
        return pose_;
    }
    
    void SetPose(const SE3 &pose){
        std::unique_lock<std::mutex> lck(pose_mutex_);
        pose_=pose;
    }
    
    void SetKeyFrame();
    
    static std::shared_ptr<Frame> CreateFrame();
};
    
        
    
    
    
    
    
    
    
};

#endif // FRAME_H
